﻿#define _CRT_SECURE_NO_WARNINGS 1
#include"game.h"
void init(char board[11][11], int rows, int cols, char set)
{
	for (int i = 0; i < rows; i++) {

		for (int j = 0; j < cols; j++) {

			board[i][j] = set;

		}

	}

}
void print(char board[ROWS][COLS], int row, int col)
{
	for (int m = 0; m <= row; m++) {


		printf("%d ", m);
	

	}
	printf("\n");
	for (int i = 1; i <= row; i++) {
		printf("%d ", i);
		
		for (int j = 1; j <= col; j++)
		{

			printf("%c ", board[i][j]);



		}

		printf("\n");


	}
}
	void Set(char board[ROWS][COLS], int row, int col)
	
		
	{    int count = NUM;
		while (count)
		{
			int x = rand() % row + 1;
			int y = rand() % col + 1;
			if (board[x][y] == '0')
			{
				board[x][y] = '1';
				count--;
			}
		}
	}

	int get(char M[ROWS][COLS], int x, int y) {

		return M[x - 1][y] + M[x + 1][y] + M[x - 1][y + 1] + M[x + 1][y + 1] + M[x - 1][y - 1] +
			M[x + 1][y - 1] +M[x][y-1]+M[x][y+1] - 8 * '0';


	}
	void find(char S[ROWS][COLS], char M[ROWS][COLS], int row, int col) {
		int x, y = 0;
		int m = 0;

		
		while (m < row * col - 10) {
			printf("请输入坐标");
			scanf("%d %d", &x, &y);
			if (x > 0 && x <= row && y > 0 && y <= col)
			{
				if (M[x][y] == '1') {
					printf("你被炸死了\n");
						print(M, ROW, COL);
						break;
				}
				else
				{
					int count = get(M, x, y);
					S[x][y] = '0' + count;
					print(S, ROW, COL);
					m++;
				}



			}
			else
			{
				printf("输入错误，重新输入\n");

			}

		}

	}